package com.jztchat.clientController;

import com.google.common.collect.Maps;
import io.swagger.models.Model;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by zzy on 2018/1/18.
 */
@Controller
@RequestMapping("/member")
public class userClientController {

    @Value("${ws.server.host}")
    private String host;

    @Value("${ws.server.port}")
    private String port;

    @GetMapping("/index.htm")
    public ModelAndView index(){
        Map<String,Object> model= Maps.newHashMap();
        model.put("socketHost",host);
        model.put("socketPort",port);
        return new ModelAndView("client",model);
    }

    @GetMapping("/client.htm")
    public ModelAndView client(HttpServletRequest request,Map model){
        String clientUser=request.getParameter("client");
        String targetClient=request.getParameter("target");
        model.put("client",clientUser);
        model.put("target",targetClient);
        model.put("socketHost",host);
        model.put("socketPort",port);
        return new ModelAndView("chatClient",model);
    }
}
